﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class admin_details_nghiphep : System.Web.UI.Page
{
    User u = new User();
    NghiPhep n = new NghiPhep();

    protected void Page_Init(object sender, EventArgs e)
    {
        BindGrid();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)

            if (Session["username"] != null &&Request.Params["id"]!=null)           
                Show_Info();           
            else { Response.Redirect("../login.aspx"); }
        else
            if (Session["username"] != null && Request.Params["id"] != null)            
                Show_Info();
            

    }
    protected void Show_Info()
    {
        u.Email = Request.Params["id"].ToString();
        BindGrid();
        lUsername.Text = Session["username"].ToString();
        Get_Info_Nghi_Phep(u.Email);
    }
    protected void BindGrid()
    {

        n.List_Nghi_Phep(gdNghiPhep, u.Email);
    
    }
    protected void Get_Info_Nghi_Phep(string email)
    {
        n = n.Get_Nghi_Phep_Info(email);
        if (n.PhepNam > 0)
            lPhepNam.Text = n.PhepNam.ToString() + " ngày";
        else
            lPhepNam.Text = "0";

        if (n.PhepDacBiet > 0)
            lNghiDacBiet.Text = n.PhepDacBiet.ToString() + " ngày";
        else
            lNghiDacBiet.Text = "0";

        if (n.NghiKhongHuongLuong > 0)
            lNghiKhongHuongLuong.Text = n.NghiKhongHuongLuong.ToString() + " ngày";
        else
            lNghiKhongHuongLuong.Text = "0";

        if (n.NghiOm > 0)
            lNghiOm.Text = n.NghiOm.ToString() + " ngày";
        else lNghiOm.Text = "0";



    }
    protected void lnkLogout_Click(object sender, EventArgs e)
    {
        Session.Clear();
        Response.Redirect("../login.aspx");
    }
    protected void gdNghiPhep_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
    {
        e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#f7f7f7';");
        if ((e.VisibleIndex % 2) == 0)
        {
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white';");
        }
        else
        {
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white';");
        }
    }

}
